<template>
  <div class="box">
    <div class="head"> 
      <div class="head-left">
        <p>郑州</p>
        <span>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-xiangxiajiantou"></use>
          </svg>
        </span>
      </div>
      <div class="inp">
        <div class="op">
          搜索
        </div>
        <input type="text" v-model="msg">
      </div>
      <div class="head-right">
        <span>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-erweima"></use>
          </svg>
        </span>
      </div>
    </div>

    <div class="store">
      <p class="store-title">
        美食百货，随叫随到
      </p>
      <div class="store-con">
        <div class="content">
          <router-link :to="item.type" class="item" tag="div" v-for="item in store" :key="item.id">
            <span class="ifont">
              <svg class="icon" aria-hidden="true">
                <use :xlink:href="`#${item.icon}`"></use>
              </svg>
            </span>
            <p>{{item.title}}</p>
          </router-link>
        </div>
      </div>
    </div>

    <div class="swiper-container">
      <div class="swiper-wrapper">
          <div class="swiper-slide">
             <div class="list">
              <router-link :to="item.type" tag="div" v-for="item in list" :key="item.id" class="list-item">
                <div class="ifont">
                  <svg class="icon" aria-hidden="true">
                        <use :xlink:href="`#${item.icon}`"></use>
                      </svg>
                </div>
                <div>
                  {{item.title}}
                </div>
              </router-link>
            </div>
          </div>
          <div class="swiper-slide">
             <div class="list">
              <router-link :to="item.type" tag="div" v-for="item in list" :key="item.id" class="list-item">
                <div class="ifont">
                  <svg class="icon" aria-hidden="true">
                        <use :xlink:href="`#${item.icon}`"></use>
                      </svg>
                </div>
                <div>
                  {{item.title}}
                </div>
              </router-link>
            </div>
          </div>
          <div class="swiper-slide">
             <div class="list">
              <router-link :to="item.type" tag="div" v-for="item in list" :key="item.id" class="list-item">
                <div class="ifont">
                  <svg class="icon" aria-hidden="true">
                        <use :xlink:href="`#${item.icon}`"></use>
                      </svg>
                </div>
                <div>
                  {{item.title}}
                </div>
              </router-link>
            </div>
          </div>
      </div>
      <!-- 如果需要分页器 -->
      <div class="swiper-pagination"></div>
      
    </div>
   

    <div class="type">
      <div class="type-item" v-for="item in data" :key="item.id">
        <div>
          <img :src="item.pic_url" alt="">
        </div>
        <div class="con">
          <h3 class="title">
            {{item.name}}
          </h3>
          <div class="timer">
            营业时间:{{item.shipping_time}}
          </div>
          <div class="text">
            {{item.wm_poi_score}}分 | {{item.distance}}
          </div>
        </div>
      </div>
    </div>
    <div>
      <router-link to="/home">点击</router-link>
    </div>
    <foot></foot>

    
  </div>


</template>

<script>
import '@/assets/iconfont/iconfont.js'
import foot from '@/components/common/foot.vue'

import Swiper from 'swiper'

import "swiper/css/swiper.css"

import {getAllPro} from '@/api/request'
export default {
  data() {
    return {
      msg:'',
      
      store:[],

      list:[],

      data:[]
    }
  },
  created(){
    getAllPro("/db").then(res=>{
      let {store} = res.data
      this.store = store
    })
    getAllPro("/db").then(res=>{
      let {list} = res.data
      this.list = list
    })

    getAllPro("/home").then(res=>{
      let {data} = res.data
      this.data = data
    })
  },
  mounted() {
    var mySwiper = new Swiper ('.swiper-container', {
    // loop: true, // 循环模式选项
    
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
    },
    
    
    })    
  },
  components:{
    foot,
  }
}
</script>
<style >
  /* .swiper {
    width: 600px;
    height: 300px;
}   */
</style>

<style lang="scss" scoped>
.icon {
  width: .7rem;
  height: .7rem;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
  margin-bottom: .05rem;
}
.box{
      background : linear-gradient(rgb(249,208,56) ,rgb(243, 243, 243) 4.54rem , rgb(244, 244, 244));  /* 这里不要有, */
      overflow: hidden;
    }
  .head{  
    margin:  .13rem 0;
    display: flex;
    width: 100%;
    height: .68rem;
    align-items: center;
    justify-content: space-around;
    // background-color: rgb(247, 206, 56);
    .head-left{
      width: 1.3rem;
      padding: 0 .1rem 0 .2rem;
      box-sizing: border-box;
      display: flex;
      text-align: center;
      .icon{
        padding-left: .08rem;
        vertical-align: middle;
        width: .3rem;
        height: .3rem;
      }
    }
    .inp{
      flex: 1;
      height: .68rem;
      border-radius: .35rem;
      position: relative;
      background-color: #fff;
      .op{
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 50%;
        margin-top: -.27rem;
        margin-right: .08rem;
        width: 1.04rem;
        text-align: center;
        border-radius: .32rem;
        height: .56rem;
        line-height: .56rem;
        background-color: #f8d93d;
        z-index: 333;
      }
      input{
        position: absolute;
        font-size: .25rem;
        color: rgb(63, 63, 63);
        left: .3rem;
        height: .68rem;
        width: 80%;
        border: none;
        &:focus{
          outline: none;
        }
    }
    }
    
    .head-right{
      width: .93rem;
      box-sizing: content-box;
      text-align: center;
      // padding: 0 .1rem;
    }
  }

  .store{
    margin:0 .14rem;
    height:  2.06rem;
    background-color: #fffefd;
    border-radius: .25rem;
    overflow: hidden;
    // flex-flow: row wrap;

    .store-title{
      // height: .18rem;
      margin: .18rem .26rem;
      font-size: .26rem;
      overflow: hidden;
      
    }
    .store-con{
      padding: .18rem;
      box-sizing: border-box;
      // height: 100%;
      .content{
        display: flex;
        justify-content: space-around;
        .item{
          font-size: .25rem;
          // background-color: #bfa;
          margin: 0 .1rem;
          height: calc(100% - .2rem);
          flex: 1;
          cursor: pointer;
          text-align: center;
          // .ifont{
          //   margin-bottom: .2rem;
          // }
        } 
      }
    }
  }

  .list{ 
    background-color: #fff;
    margin: .12rem .14rem 0 .14rem;
    border-radius: .23rem;
    height: 4.56rem;
    display: flex;
    flex-flow: row wrap;
    align-content: space-around;
    justify-content: space-around;
    .list-item{
      font-size: .26rem;
      cursor: pointer;
      align-items: center;
      box-sizing: border-box;
      margin: .15rem .15rem;
      height: calc(100% / 3 - .3rem);
      width: calc(20% - .3rem);
      // background-color: red;
      display: flex;
      flex-flow: column nowrap;
      justify-content: center;

    }
  }

  .type{
    margin: 0 .21rem 1.3rem .21rem;
    display: flex;
    justify-content: space-between;
    flex-flow: row wrap;
    align-items: center;
    overflow: hidden;
    .type-item{
      cursor: pointer;
      width: 3.86rem;
      margin-top: .14rem;
      border-radius: .2rem;
      img{
        border-radius: .3rem;
        width: 3.86rem;
      }

      .con{
        margin: .1rem .2rem;
        
        h3{
          font-size: .35rem;
          text-overflow:ellipsis;     
          white-space:nowrap;   
          overflow:hidden; 
          margin-bottom:.1rem;
        }

        .timer{
          margin-bottom:.1rem;
          color: #f60;
        }
        .text{
          margin-bottom:.1rem;
        }
      }
    }
  }
</style>